﻿using System;
using Microsoft.Phone.Tasks;
using Caliburn.Micro;

namespace CCWP7.CaliburnMicro
{
    public class AboutPageViewModel : Screen
    {
        readonly IEventAggregator _eventAggregator;
        readonly INavigationService _navigationService;
        readonly IProductVersion _productVersion;

        public AboutPageViewModel(INavigationService navigationService, IProductVersion productVersion, IEventAggregator eventAggregator)
        {
            _eventAggregator = eventAggregator;
            _navigationService = navigationService;
            _productVersion = productVersion;
        }

        public string Version
        {
            get
            {
                return _productVersion.GetVersion();
            }
        }

        string _browserTargetUri;
        public void CCNet()
        {
            _browserTargetUri = "http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET";

            _eventAggregator.RequestTask<WebBrowserTask>(t => t.Uri = new Uri(_browserTargetUri));
        }

        public void ProjectPage()
        {
            _browserTargetUri = "http://ccnetwp7.codeplex.com/";
            _eventAggregator.RequestTask<WebBrowserTask>(t => t.Uri = new Uri(_browserTargetUri));
        }

        public void CodeProjectArticle()
        {
            _browserTargetUri = "http://www.codeproject.com/KB/windows-phone-7/CaliburnMicro4WP7.aspx";
            _eventAggregator.RequestTask<WebBrowserTask>(t => t.Uri = new Uri(_browserTargetUri));
        }

        public void EMailSupport()
        {
            _eventAggregator.RequestTask<EmailComposeTask>(t =>
            {
                t.Subject = "CCNet Monitor for Phone";
                t.To = "nz-bee@live.com";
            });
        }

        public void OtherApps()
        {
            _eventAggregator.RequestTask<MarketplaceSearchTask>(t => t.SearchTerms = "nz bee");
        }
    }
}
